<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="commons::common_header"><!-- 引入头文件 -->
</head>
<body>
<link rel="stylesheet" th:href="@{/static/css/zTreeStyle.css}"/>
<link rel="stylesheet" th:href="@{/static/css/jquery-ui.min.css}"/>
<link rel="stylesheet" th:href="@{/static/css/jquery-ui-1.10.4.custom.css}"/>
<link rel="stylesheet" th:href="@{/static/css/bootstrap-datetimepicker.css}"/>
<nav th:replace="commons::common_nav"></nav><!-- 引入导航栏 -->
<div th:replace="commons::common_pwdmodal"></div><!-- 引入密码修改框 -->
<!-- 系统日志模块整理视图 -->
<div class="container" style="width: 1500px; margin-top: 50px">
    <div class="panel panel-default" style=" width: 98%; margin-left: 1%;">
        <!-- 表头 -->
        <div class="panel-heading">
            <div class="pull-right">
                <div class="btn-group">
                    <button type="button" class="btn btn-success" onclick="location.reload()">
                        刷新
                    </button>
                </div>
            </div>
            <h5> 系统日志 </h5>
        </div>

        <!-- 表格主体 -->
        <div class="panel-body">
            <!-- 主体左侧树状目录 -->
            <div class="panel panel-default col-sm-2" style="overflow-y:auto; overflow-x:auto; width:280px; height: 650px; padding-top: 10px">
                <ul id="syslogTree" class="ztree"></ul>
            </div>

            <!-- 主体右侧软件信息表格 -->
            <div class="panel panel-default col-sm-10" style=" left:10px; width:1100px; height:650px;">
                <div class="panel-heading " style="padding: 0px;">
                    <div style="display: inline-block;width: 100%;">
                        <div class=" col-sm-12">
                            <form class="form-inline" role="form" id="queryform" name="queryform" action="/mlp/syslog/list" method="post">
                                <!--suppress ALL--><!-- 该注解决EL表达式报错——关闭检测下一行表达式 -->
                                <input id="type" type="hidden" th:value="${type}"><!-- 焦点所在节点 -->
                                <div class="btn-group"><!--suppress ALL-->
                                    <input size="20" type="text" id="loginfo" name="loginfo" th:value="${loginfo}"
                                           placeholder="请输入日志内容" maxlength="100"
                                           style="width: 300px;padding-bottom: 0px;padding-top: 0px;height: 34px;">
                                </div>
                                <div class="btn-group" style="margin-top: 5px;margin-bottom: 5px;">
                                    <div class="input-group date form_datetime"><!--suppress ALL-->
                                        <input size="20" type="text" id="startDate_createTime"
                                               name="startDate_createTime" th:value="${start}" class="form-control"
                                               readonly placeholder="请选择开始时间">
                                            <span class="input-group-addon">
						                        <span class="glyphicon glyphicon-calendar"></span>
						                    </span>
                                    </div>
                                </div>
                                <div class="btn-group" style="margin-top: 5px;margin-bottom: 5px;">
                                    <div class="input-group date form_datetime"><!--suppress ALL-->
                                        <input size="20" type="text" id="endDate_createTime" name="endDate_createTime"
                                               th:value="${end}" class="form-control" readonly placeholder="请选择结束时间">
                                            <span class="input-group-addon">
						                        <span class="glyphicon glyphicon-calendar"></span>
						                    </span>
                                    </div>
                                </div>
                                <div class="btn-group">
                                    <button type="button" class="btn btn-primary" onclick="qurrybytime()">查询</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <table class="table table-striped line row scroll-bar" style="table-layout: fixed; display:block; height: 500px; overflow: auto"><!--suppress ALL-->
                    <thead th:if="${datalist.size() > 0}">
                    <tr>
                        <th>
                            <input type="checkbox" id="checkRow_head" name="checkRow_" value="" onclick="checkPageSelected_(this);"/>
                        </th>
                        <th>类型</th>
                        <th>内容</th>
                        <th>时间</th>
                        <th>IP</th>
                        <th>备注</th>
                    </tr>
                    </thead><!--suppress ALL-->
                    <tbody th:if="${datalist.size() > 0}">
                    <!--suppress ALL-->
                    <tr th:each="syslog : ${datalist}">
                        <th scope="row"><!--suppress ALL-->
                            <input type="checkbox" name="checkRow_" onclick="checkRowSelected_(this)"/>
                        </th><!--suppress ALL-->
                        <td th:text="${syslog.option}" style="width: 15%"></td><!--suppress ALL-->
                        <td th:text="${syslog.loginfo}" style="width: 25%"></td><!--suppress ALL-->
                        <td th:text="${#dates.format(syslog.timestamp,'yyyy-MM-dd HH:mm:ss')}"  style="width: 20%"></td><!--suppress ALL-->
                        <td th:text="${syslog.userip}"  style="width: 15%"></td><!--suppress ALL-->
                        <td th:text="${syslog.remark}"  style="width: 20%"></td><!--suppress ALL-->
                    </tr>
                    </tbody><!--suppress ALL-->
                    <tbody th:if="${datalist.size() == 0}">
                    <div class="pagenodate" style="padding-top: 50px"><label style="color:red;">没有符合您要求的记录</label></div>
                    </tbody>
                </table>
                <!-- 分页组件 -->
                <div th:replace="commons::common_paginater"></div>
            </div>
        </div>
    </div>
</div>

<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/js/jquery-ui.min.js}"></script>
<script th:src="@{/static/js/jquery.ztree.all-3.5.min.js}"></script>
<script th:src="@{/static/js/bootstrap-datetimepicker.js}"></script>
<script th:src="@{/static/js/bootstrap-datetimepicker.zh-CN.js}"></script>
<script th:inline="javascript">
    /**---- 初始化日历控件 ----*/
    $(".form_datetime").datetimepicker({
        format: "yyyy-mm-dd hh:ii:00",
        autoclose: true,
        todayBtn: true,
        clearBtn: true,
        language: 'zh-CN',
        pickerPosition: "bottom-left",
        minView: 0
    });

    /** -----表格左侧树状目录加载组方法 start----- **/
    /* 设置树形目录参数 */
    var setting = {
        view: {
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeClick: zTreeBeforeClick
        }
    };

    /* 初始化查询,保留之前的选中状态 */
    var zNodes = [[${menuTreeBeans}]];
    var zTree;
    $(document).ready(function () {
        zTree = $.fn.zTree.init($("#syslogTree"), setting, zNodes);
        var treeObj = $.fn.zTree.getZTreeObj("syslogTree");
        var type = $('#type').val();
        var node = null;
        if (type != "") {
            node = treeObj.getNodeByParam("id", type, null);
        }
        if (node != null) {
            $("#" + node.tId + "_a").attr('class', 'curSelectedNode');
        }
    });

    /* 点击项目树查询: treeNode.id（为节点id），treeNode.pid（父节点id），treeNode.tId（菜单名_节点自然顺序） */
    function zTreeBeforeClick(treeId, treeNode, clickFlag) {
        var start = $("#startDate_createTime").val();
        var end = $("#endDate_createTime").val();
        if (treeNode.getParentNode() == null) {
            /*若没有父节点,则父节点为根节点，向一级菜单跳转*/
            location.href = "/mlp/syslog/list?type=0&start="+ start +"&end="+ end + "&pageSize=" + $("#pageSize").val();
        } else {
            /*若父节点存在，则该节点为叶子节点，根据条件跳转*/
            location.href = "/mlp/syslog/list?type=" + treeNode.id  +"&start="+ start +"&end="+ end + "&pageSize=" + $("#pageSize").val();
        }
    };
    /** -----表格左侧树状目录加载组方法 end----- **/


    /** ------ 点击查询按钮查询树状目录 -------- */
    function qurrybytime() {
        var type = $('#type').val();
        var start = $("#startDate_createTime").val();
        var end = $("#endDate_createTime").val();
        var loginfo = $("#loginfo").val();
        if((start != "" && end == "")||(start == "" && end != "")){
            alert("请将起止时间选择完整！")
            return
        }
        if(start > end){
            alert("开始时间不得晚于结束时间！")
            return
        }
        location.href = "/mlp/syslog/list?type="+ type +"&start="+ start +"&end="+ end +"&loginfo="+ encodeURI(loginfo)
            +"&page=1" + "&pageSize=" + $("#pageSize").val();
    }
</script>
</body>
</html>
